/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.webapp.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Tonytran
 */
@Entity
@Table(name = "courseteacher")
//@AssociationOverrides({@AssociationOverride(name = "coursing",joinColumns = @JoinColumn(name = "id")) })
public class Coursing implements Serializable {

    @Id
    @GeneratedValue
    @Column(name = "courseteacher_id")
    private int courseteacher_id;
    
    @Column(name = "course_id")
    private int course_id;
    
    @Column(name = "teacher_id")
    private int teacher_id;
    
    @Column(name = "session_id")
    private int session_id;
    
    @OneToMany(mappedBy = "coursing", cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
    //@JoinColumn(name="courseteacher_id", insertable = false, updatable = false)
    private List<Classing> classing;

    //@OneToOne(mappedBy = "coursesdetail", fetch = FetchType.LAZY)
    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name="course_id", insertable = false, updatable = false, nullable=false ,unique=true)
    private Courses courses;
    
    //@OneToOne(mappedBy = "teachersdetail", cascade={CascadeType.ALL}, fetch = FetchType.LAZY)
    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name="teacher_id", insertable = false, updatable = false, nullable=false ,unique=true)
    private Teachers teachers;
    
    //@OneToOne(mappedBy = "sessionsdetail", cascade={CascadeType.ALL}, fetch = FetchType.LAZY)
    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name="session_id",insertable = false, updatable = false)
    private Sessions sessions;
    
    //@Transient
    //public Classes classes;
    //@OneToMany(targetEntity=Classing.class, mappedBy="ocoursing")
    
    @Transient
    public List<Classes> classes;

    public int getCourseteacher_id() {
        return courseteacher_id;
    }

    public void setCourseteacher_id(int courseteacher_id) {
        this.courseteacher_id = courseteacher_id;
    }

    public int getCourse_id() {
        return course_id;
    }

    public void setCourse_id(int course_id) {
        this.course_id = course_id;
    }

    public int getTeacher_id() {
        return teacher_id;
    }

    public void setTeacher_id(int teacher_id) {
        this.teacher_id = teacher_id;
    }

    public int getSession_id() {
        return session_id;
    }

    public void setSession_id(int session_id) {
        this.session_id = session_id;
    }

    public List<Classing> getClassing() {
        return classing;
    }

    public void setClassing(List<Classing> classing) {
        this.classing = classing;
    }

    public Courses getCourses() {
        return courses;
    }

    public void setCourses(Courses courses) {
        this.courses = courses;
    }

    public Teachers getTeachers() {
        return teachers;
    }

    public void setTeachers(Teachers teachers) {
        this.teachers = teachers;
    }

    public Sessions getSessions() {
        return sessions;
    }

    public void setSessions(Sessions sessions) {
        this.sessions = sessions;
    }

    public List<Classes> getClasses() {
        return classes;
    }

    public void setClasses(List<Classes> classes) {
        this.classes = classes;
    }
}
